package com.contest.util;



import java.util.HashMap;
import java.util.Map;
import java.util.Random;
public class RandomUtil {
    public static Integer king = 0;
    public static Integer wilderness = 0;
    public static Integer hero = 0;

    public static Map<String,String> king() {
        Random random = new Random();
        Integer num = random.nextInt(10000000) * 10;
        if (randomTrend() % 2 == 0) {
            if (king != 0) {
                king -= randomMargin();
            } else {
                king = num - randomMargin();
            }
        } else {
            if (king != 0) {
                king += randomMargin();
            } else {
                king = num + randomMargin();
            }
        }
        Map<String,String> temp = new HashMap<String,String>();
        temp.put(DateUtil.now(),king+"");
        return temp;
    }

    public static Map<String,String> wilderness() {
        Random random = new Random();
        Integer num = random.nextInt(10000000) * 10;
        if (randomTrend() % 2 == 0) {
            if (wilderness != 0) {
                wilderness -= randomMargin();
            } else {
                wilderness = num - randomMargin();
            }
        } else {
            if (wilderness != 0) {
                wilderness += randomMargin();
            } else {
                wilderness = num + randomMargin();
            }
        }
        Map<String,String> temp = new HashMap<String,String>();
        temp.put(DateUtil.now(),wilderness+"");
        return temp;
    }

    public static Map<String,String> hero() {
        Random random = new Random();
        Integer num = random.nextInt(10000000) * 10;
        if (randomTrend() % 2 == 0) {
            if (hero != 0) {
                hero -= randomMargin();
            } else {
                hero = num - randomMargin();
            }
        } else {
            if (hero != 0) {
                hero += randomMargin();
            } else {
                hero = num + randomMargin();
            }
        }
        Map<String,String> temp = new HashMap<String,String>();
        temp.put(DateUtil.now(),hero+"");
        return temp;
    }



     static int randomTrend() {
        Random random = new Random();
        return random.nextInt(10);
    }

     static int randomMargin() {
        Random random = new Random();
        return random.nextInt(10000);
    }

    public static void main(String[] args) {
        System.out.println(king());
        System.out.println(wilderness());
        System.out.println(hero());
        System.out.println(getRate());
    }

    public static String getRate(){
        Random random = new Random();
        int rate = random.nextInt(50)+20;
        return rate+"%";
    }

    /**
     * 生成在[min,max]之间的随机整数
     *
     * @param min
     * @param max
     * @return
     */
    public static int randomNumber(int min, int max)
    {
        Random random = new Random();
        int s = random.nextInt(max) % (max - min + 1) + min;
        return s;
    }

}
